package aop02;

import java.lang.reflect.Proxy;

/**
 * Author:shixiaojun@itany.com
 * Date:2022/5/17 15:57
 * Version:1.0-SNAPSHOT
 * Description:
 */
public class Test {

    public static void main(String[] args) throws SomeException {
        // 参数一:定义代理的目标类的类加载器
        // 参数二:代理的目标类要实现的接口列表
        // 参数三:指派方法调用的调用处理程序,即:交叉业务逻辑
        SomeService someService = (SomeService) Proxy.newProxyInstance(
                SomeServiceImpl.class.getClassLoader(),
                SomeServiceImpl.class.getInterfaces(),
                new LogInvocationHandler(new SomeServiceImpl())
        );
        someService.doSome();
        System.out.println("-------------------------");
        someService.doOther();
        System.out.println("-------------------------");
        someService.add(1,2);
    }

}
